home *** CD-ROM | disk | FTP | other *** search
- /*
- * @(#)FilterOutputStream.java 1.12 95/12/19 Jonathan Payne
- *
- * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for NON-COMMERCIAL purposes and without
- * fee is hereby granted provided that this copyright notice
- * appears in all copies. Please refer to the file "copyright.html"
- * for further important copyright and licensing information.
- *
- * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
- * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
- */
-
- package java.io;
-
- /**
- * Abstract class representing a filtered output stream of bytes.
- * This class is the basis for enhancing output stream functionality.
- * It allows multiple output stream filters to be chained together,
- * each providing additional functionality.
- * @version 1.12, 12/19/95
- * @author Jonathan Payne
- */
- public
- class FilterOutputStream extends OutputStream {
- /**
- * The actual output stream.
- */
- protected OutputStream out;
-
- /**
- * Creates an output stream filter.
- * @param out the output stream
- */
- public FilterOutputStream(OutputStream out) {
- this.out = out;
- }
-
- /**
- * Writes a byte. Will block until the byte is actually
- * written.
- * @param b the byte
- * @exception IOException If an I/O error has occurred.
- */
- public void write(int b) throws IOException {
- out.write(b);
- }
-
- /**
- * Writes an array of bytes. Will block until the bytes
- * are actually written.
- * @param b the data to be written
- * @exception IOException If an I/O error has occurred.
- */
- public void write(byte b[]) throws IOException {
- write(b, 0, b.length);
- }
-
- /**
- * Writes a subarray of bytes. To be efficient it should
- * be overridden in a subclass.
- * @param b the data to be written
- * @param off the start offset in the data
- * @param len the number of bytes that are written
- * @exception IOException If an I/O error has occurred.
- */
- public void write(byte b[], int off, int len) throws IOException {
- for (int i = 0 ; i < len ; i++) {
- out.write(b[off + i]);
- }
- }
-
- /**
- * Flushes the stream. This will write any buffered
- * output bytes.
- * @exception IOException If an I/O error has occurred.
- */
- public void flush() throws IOException {
- out.flush();
- }
-
- /**
- * Closes the stream. This method must be called
- * to release any resources associated with the
- * stream.
- * @exception IOException If an I/O error has occurred.
- */
- public void close() throws IOException {
- flush();
- out.close();
- }
- }
-